#模拟鼠标点击
@.simulateClick = (element, modifiers)->
	modifiers ||= {}
	eventSequence = ["mouseover", "mousedown", "mouseup", "click"]
	element.scrollIntoView()
	#计算坐标
	coordinate = element.getBoundingClientRect()
	offsetX = Math.ceil(Math.random()*coordinate.width)
	offsetY = Math.ceil(Math.random()*coordinate.height)
	for event in eventSequence
		mouseEvent = document.createEvent("MouseEvents")
		mouseEvent.initEvent event,on,on,window,1,coordinate.left+offsetX,coordinate.top+offsetY,screenLeft+coordinate.left+offsetX,screenTop+coordinate.top+offsetY,modifiers.ctrl,modifiers.alt,modifiers.shift,modifiers.meta,1,null
		element.dispatchEvent(mouseEvent)
#不使用代理
@.noProxy = ->
	config =
		mode: "system"
	chrome.proxy.settings.set({value:config,scope:'regular'},->
		'no proxy'
	)

#删除所有cookies
@.delCook = (all)->
	data = {appcache:on,cookies :on,downloads:on,fileSystems :on,formData :on,history:on,indexedDB :on,localStorage :on,pluginData :on, passwords:on,webSQL :on}
	data.cache=on if all
	chrome.browsingData.remove {since:0},data
#html转意
@.htmlEncode = (str)->
	if typeof(str) == "string"
		return str.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/\"/g, "&quot;").replace(/\'/g, "&apos;")
	"" #这是最默认返回值。
#debug
chrome.storage.local.get 'debug',(item)->
	unless item?.debug
		strFn = ['debug','log','error','count','warn']
		for i in strFn
			window.console[i] = ->
				i
#服务器
@serverUrlPre = 'http://visitweb.allalla.com/index.php?s='
